#include <sys/types.h>
#include <sys/stat.h>
 #include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(void)
{
int fd ;
int ret;

fd = open("./test.txt",O_WRONLY | O_CREAT | O_EXCL,0644);
if (-1 == fd){
printf("open error\n");
return 1;
}
printf ("open OK!\n");
ret = write(fd,"heiio world",11);
if (-1 == ret){
printf("write error\n");
close(fd);
return 1;
}

printf ("write %d byte ok\n",ret);

close (fd);

return 0;
}

